home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 32
/
Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso
/
Aminet
/
text
/
edit
/
CedBar.lha
/
CedBar
/
cedbar.gc
< prev
next >
Wrap
Text File
|
1999-05-10
|
16KB
|
594 lines
G4C
; $VER: CedBar.gc 3.5 ( by dck - 20.8.98 )
; ----------------------------------------------------------------------
; A GUI providing a toolbar for the CygnusEd text editor.
; This is a work in perpetual progress, as I use it myself..
; CygnusEd is a commercial product from ASDG Inc. (AFAIK)
; What we do is define various icons, which we use as if they
; were buttons and send the appropriate rexx command to $cedport,
; which contains the name of the current CEd's arexx port.
; According to your monitor/resolution/font etc the Icon-buttons may
; seem too small or too big - just redesign them to your liking.
; =======================================================================
WINBIG -1 0 625 14 "" ; note : no title - since don't want borders
WinType 000010
; winbackground pattern 3 2 ; try it..
varpath 'cedbar.g/cedmark.g'
UseTopaz ; because it's a non-resizable window
; -----------------------------------------------------------
; on loading
; -----------------------------------------------------------
xOnLoad ; On Loading set the default values...
cedname = CEd ; << **** PUT HERE THE FULL PATH OF CED ********
cedClip = 0
cedMark = 1
cedSend = ""
cedFile = ""
newflag = 0
Update cedbar.gc 1 $cedClip
setgad cedbar.gc 20 HIDE ; hide listview
setgad cedbar.gc 11/12 HIDE ; hide amiga guide & launch mode icons
barmode = NORMAL ; or GUIDE - can add more..
GuiClose cedbar.g ; Close the small window (if it was open)
gosub cedbar.gc StartUpCed ; See which ced is calling us
if $$sys.fsn[0][6] != 'Cygnus' ; if we are called from an other screen
cedscreen = CygnusEdScreen ; get the 1st ced's screen name
instance = $cedport[-1][1]
if $instance > 0
and $instance <= 9
appvar cedscreen $($instance + 1)
else
appvar cedscreen 1
endif
; work around... (screen name is converted to capitals & not found..)
; guiscreen #$cedscreen front ; force ced to front !!! doesn't work !!!
setscreen #this $cedscreen
guiopen cedbar.gc
guiscreen #this front
setscreen #this '*'
else
GuiOpen cedbar.gc
endif
GuiLoad :cedbar.g ; the small bar
GuiLoad :cedMark.g ; the Mark Set/Go window
GuiLoad :cedclip.g ; clipboard viewer
guiload :filereq.gc ; the file requester
; see under which ced we're running..
info gui cedbar.gc
cedscreen = $$win.screen
cedport = rexx_ced
if $cedscreen[0][6] == 'Cygnus' ; make sure it's a ced pubscreen
instance = $cedscreen[-1][1] ; get last letter
if $instance > 1
and $instance <= 9 ; adjust port name (if needed)
appvar cedport $($instance - 1)
endif
endif
; find & load the Gui4Cli extension which provides us with
; extra commands we can use with the CALL command
ifexists port LVFormat
call LVFormat Register ; notify it that we want it too
else
; look in our dir..
extract cedbar.gc guipath mypath
joinfile $mypath lvformat progname
joinfile $progname lvformat progname
ifexists file $progname
run $progname
elseifexists file guis:ext/lvformat/lvformat
run guis:ext/lvformat/lvformat
else
ezreq 'Could not find LVFormat!' OK ''
endif
endif
; -----------------------------------------------------------
; ending events
; -----------------------------------------------------------
xONQuit
GuiQuit cedbar.g ; unload all the other GUIs
GuiQuit cedmark.g
guiquit cedclip.g
guiquit addlink.g
guiquit addeffect.g
guiquit addnode.g
guiquit indent.g
guiquit wrap.g
guiquit filereq.gc
ifexists port LVFormat ; quit out handler
call LVFormat quit
endif
ifexists file t:tempnode
delete t:tempnode
endif
xonfail
guiwindow cedbar.gc resume
; -----------------------------------------------------------
; Routine - Find ced
; -----------------------------------------------------------
xRoutine StartUpCed
local count
count = 1
portname = rexx_ced
; look for any instance of ced
ifexists port ~rexx_ced
while $count < 10
IfExists PORT 'rexx_ced$count'
portname = 'rexx_ced$count'
return
endif
++count
endwhile
else
return
endif
run '$cedname' ; not found - start it up
Wait PORT rexx_ced 30 ; wait for ced to load
if $$RETCODE > 0
ezreq "CygnusEd was not found!" EXIT ""
GuiQuit cedbar.gc
Stop
endif
Wait SCREEN CygnusEdScreen1 30 ; if Screen does not open, use WB
portname = rexx_ced
; -----------------------------------------------------------
; window handling events
; -----------------------------------------------------------
xOnRMB ; rotate the last 8 buttons
; GuiClose cedbar.gc
; GuiOpen cedbar.g
gosub cedbar.gc guichange
XICON 2 0 :icons/wnClose ; the Q icon
ezreq "Last chance..\nQuit ?" YES|CANCEL choice
if $choice = 1
GuiQuit cedbar.gc
endif
XICON 15 1 :icons/right ; the > icon togle big/small windows
GuiClose cedbar.gc
GuiOpen cedbar.g
; -----------------------------------------------------------
; New file
; -----------------------------------------------------------
XICON 30 0 :icons/New
SendRexx $cedport "open new"
; -----------------------------------------------------------
; Open file
; -----------------------------------------------------------
; ----- use "filereq.gc" (if it exists in our dir - else ASL)
XICON 55 0 :icons/Open
newflag = 1 ; set flag to know that we pressed the open button
extract cedbar.gc guipath frqpath
joinfile $frqpath filereq.gc frq
joinfile $frqpath CedFav fav
ifexists file $frq
; get the current filename so we can get it's path
sendrexx $cedport 'status filename'
filename = $$rexxret
extract filename path path
; load & open fireq.gc
extract frq unquote frq
guiload $frq cedbar.gc LoadFile $cedbar.gc/path $fav
else
; if no filereq.gc open normally
SendRexx $cedport "open"
endif
; ----- the routine that will be called from filereq.gc for *every*
; file chosen in it's listview
xroutine LoadFile filename
; if there have been changes made or it's an existing file - open a new file
sendrexx $cedport 'status numchanges'
changes = $$rexxret
if $newflag = 0
or $changes > 0
SendRexx $cedport "open new"
endif
newflag = 0 ; set flag = all next files (multiselected) => open new view
SendRexx $cedport 'open $filename'
; ------ add current path to the filename - store it in cedbar.gc/fn
xroutine makefile fn
local pth
extract cedbar.gc guipath pth
joinfile $pth $fn fn
; -----------------------------------------------------------
; View handling icons
; -----------------------------------------------------------
XICON 80 0 :icons/Big
SendRexx $cedport "expand view"
; -----------------------------------------------------------
; Save as.., Save
; -----------------------------------------------------------
XICON 95 0 :icons/saveas
SendRexx $cedport "save as"
XICON 120 0 :icons/save
SendRexx $cedport "save"
; -----------------------------------------------------------
; Quit
; -----------------------------------------------------------
XICON 145 0 :icons/quit
; get information
sendrexx $cedport 'status numchanges'
changes = $$rexxret
sendrexx $cedport 'status filename'
filename = $$rexxret
sendrexx $cedport 'status totalnumviews'
views = $$rexxret
if $changes > 0
ezreq '$changes changes have been made.\nQuit $filename ?\n' 'Quit|Save & Quit|CANCEL' choice
if $choice = 0
stop
elseif $choice = 2
SendRexx $cedport "save"
; we will quit later..
endif
endif
if $views = 1 ; this is the last file - give him one more chance..
ezreq 'Really quit ?' "Quit!|CANCEL" choice
if $choice = 0
stop
endif
; the guy just won't listen to reason..
guiclose cedbar.gc ; close window so ced can quit
guiclose cedmark.g
guiquit cedbar.gc ; and quit.. (after all commands have executed)
endif
SendRexx $cedport "quit"
; -----------------------------------------------------------
; Cut & Paste
; -----------------------------------------------------------
XICON 170 0 :icons/cut
SendRexx $cedport cut
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
XICON 195 0 :icons/copy
SendRexx $cedport copy
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
XICON 220 0 :icons/paste
SendRexx $cedport paste
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
; -----------------------------------------------------------
; Change the clipboard unit (use cedclip.g)
; -----------------------------------------------------------
XAREA 246 0 40 14 box ; use an area gad to get button click over
guiopen cedclip.g ; the text gad below..
TEXT 246 1 40 12 "" 10 box ; the number of the clipboard unit
GadID 1
XICON 287 1 :icons/Up ; the up/down icons
++cedClip
gosub cedclip.g changeunit
XICON 287 7 :icons/Down
--cedClip
gosub cedclip.g changeunit
; -----------------------------------------------------------
; Undo/Redo, Find & Replace
; -----------------------------------------------------------
XICON 300 0 :icons/undo
SendRexx $cedport "undo"
XICON 315 0 :icons/redo
SendRexx $cedport "redo"
XICON 330 0 :icons/find
SendRexx $cedport "search for"
XICON 356 1 :icons/right
SendRexx $cedport "repeat search forwards"
XICON 370 0 :icons/replace
SendRexx $cedport "replace"
XICON 396 1 :icons/right
SendRexx $cedport "repeat replace"
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; change gui..
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
XICON 410 0 :icons/change
gosub cedbar.gc guichange
xroutine guichange ; also called from xOnRMB
if $barmode = NORMAL
barmode = GUIDE
setgad cedbar.gc 10 HIDE
setgad cedbar.gc 12 HIDE
setgad cedbar.gc 11 SHOW
elseif $barmode = GUIDE
barmode = LAUNCH
setgad cedbar.gc 10/11 HIDE
setgad cedbar.gc 12 SHOW
else ; LAUNCH mode
barmode = NORMAL
setgad cedbar.gc 11/12 HIDE
setgad cedbar.gc 10 SHOW
endif
partredraw cedbar.gc 430 0 625 14
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; gadid 10
; ===========================================================
; NORMAL mode
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
xICON 425 0 :icons/all
gadid 10
SendRexx $cedport "beg of file"
SendRexx $cedport "mark"
SendRexx $cedport "end of file"
xICON 450 0 :icons/goto
gadid 10
GuiOpen cedmark.g
xICON 475 0 :icons/clear
gadid 10
SendRexx $cedport "clear"
xICON 500 0 :icons/colmark
gadid 10
SendRexx $cedport "mark columnar"
xICON 525 0 :icons/brackets
gadid 10
SendRexx $cedport "find matching bracket"
xICON 550 0 :icons/print
gadid 10
SendRexx $cedport "print file"
xICON 575 0 :icons/empty
gadid 10
xICON 600 0 :icons/nextced
gadid 10
guiclose cedbar.gc
SendRexx $cedport "activate next ced"
if $$rexxret > "0" ; if there is a next ced
cedport = $$rexxret ; the new port name
SendRexx $cedport "status pubscreenname"
cedscreen = $$rexxret
endif
guiopen cedbar.gc
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; gadid 11
; ===========================================================
; GUIDE mode - Amiga Guide editor
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; create a new guide
; -----------------------------------------------------------
xICON 425 0 :icons/AGNew
gadid 11
guiload :addnode.g GUIDE
; -----------------------------------------------------------
; split an existing guide
; -----------------------------------------------------------
xICON 450 0 :icons/AGSplit
gadid 11
guiload :splitguide.g
; -----------------------------------------------------------
; join nodes into a guide
; -----------------------------------------------------------
xICON 475 0 :icons/AGJoin
gadid 11
guiload :joinguide.g
; -----------------------------------------------------------
; create new node
; -----------------------------------------------------------
xICON 500 0 :icons/AGNode
gadid 11
guiload :addnode.g NODE
; -----------------------------------------------------------
; make link
; -----------------------------------------------------------
xICON 525 0 :icons/AGLink
gadid 11
guiload :addlink.g
; -----------------------------------------------------------
; add effect
; -----------------------------------------------------------
xICON 550 0 :icons/AGfx
gadid 11
guiload :addeffect.g
; -----------------------------------------------------------
; mormalize selected text (i.e. remove @{..)
; -----------------------------------------------------------
xICON 575 0 :icons/AGClear
gadid 11
; cut the selected text into our lv
SendRexx $cedport cut
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
; ask the CedHandler program to process it
call LVFormat agclean
; paste it back into ced
lvsave 'CLIPS:$cedClip'
SendRexx $cedport paste
; -----------------------------------------------------------
; view this node
; -----------------------------------------------------------
xICON 600 0 :icons/eye
gadid 11
guiwindow cedmark.g wait
; close previous window & file, if any
ifexists port CEDGUIDE
sendrexx CEDGUIDE QUIT
endif
; get current file name
sendrexx $cedport 'status filename'
filename = $$rexxret
; save file if it's been changed
sendrexx $cedport 'status numchanges'
if $$rexxret > 0
sendrexx $cedport 'save'
endif
; load into lv, make it a node, save as tempnode & show it
lvuse cedbar.gc 20
lvchange $filename
lvgo first
if $$lv.rec[0][5] == "@data"
; if it's a node add the @database stuff..
else
lvinsert -1 '@database Test\n@node MAIN "Main"\n'
lvadd '@endnode\n'
endif
lvsave t:tempnode
run 'amigaguide t:tempnode screen=$cedscreen port=CEDGUIDE'
guiwindow cedmark.g resume
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
; gadid 12
; ===========================================================
; LAUNCH mode
; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
xICON 425 0 :icons/indent
gadid 12
guiload :indent.g
xICON 450 0 :icons/unindent
gadid 12
SendRexx $cedport cut
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
call LVFormat UnIndent
lvsave 'CLIPS:$cedClip'
SendRexx $cedport paste
xICON 475 0 :icons/wrap
gadid 12
guiload :wrap.g
xICON 500 0 :icons/empty
gadid 12
; get selected text
SendRexx $cedport cut
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
txt = $$lv.rec
sendrexx $cedport "text #define $txt\tMakeID(\'$txt[0][1]\',\'$txt[1][1]\',\'$txt[2][1]\',\'$txt[3][1]\')\t\t// "
xICON 525 0 :icons/empty
gadid 12
xICON 550 0 :icons/search
gadid 12
gosub cedbar.gc getname
if $textpath < ' '
textpath = sys:
endif
; put selected text into search for box
SendRexx $cedport copy
lvuse CedClip.g 1
lvchange 'CLIPS:$cedClip'
; load a slightly modified version of guis:g4c/fsearch.gc
guiload :fsearch.gc '$textpath' '$$lv.rec'
xICON 575 0 :icons/calc
gadid 12
guiload :calc.gc ; also in guis:tools
xICON 600 0 :icons/info
gadid 12
local path/guidename ; local vars
; close previous guide if any
ifexists port CEDGUIDE
sendrexx CEDGUIDE QUIT
endif
extract cedbar.gc guipath path
joinfile $path CedBar.guide guidename
run 'amigaguide $guidename screen=$cedscreen port=CEDGUIDE'
; -----------------------------------------------------------
; a hidden listview - used for file manipulation
; -----------------------------------------------------------
XLISTVIEW 0 0 87 110 '' lvr '' 0 MULTI
gadid 20
; -----------------------------------------------------------
; routine to get current filename & path
; -----------------------------------------------------------
xroutine getname
sendrexx $cedport 'status filename'
filename = $$rexxret
extract filename path textpath